package org.eclipse.emf.cdo.ui.merge;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.cdo.ui.merge.TreeParent;

/**
 * Basic Tree Object for the tree view.
 * Each node has a name and a reference to a parent (null if root element).
 * @author Thomas Halmetschlager
 *
 */
public class TreeObject implements IAdaptable {
	
	/** The name of the node. */
	private String name;
	
	/** The reference to the parent node. */
	private TreeParent parent;
	
	/**
	 * Instantiates a new tree object.
	 *
	 * @param name the name
	 */
	public TreeObject(String name) {
		this.name = name;
	}
	
	/**
	 * Returns the name of the node.
	 *
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	
	/**
	 * Sets the parent.
	 *
	 * @param parent the new parent
	 */
	public void setParent(TreeParent parent) {
		this.parent = parent;
	}
	
	/**
	 * Returns the parent.
	 *
	 * @return the parent
	 */
	public TreeParent getParent() {
		return parent;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return getName();
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
	 */
	public Object getAdapter(Class key) {
		return null;
	}
	
	/**
	 * Sets the name.
	 *
	 * @param name the new name
	 */
	public void setName(String name){
		this.name = name;
	}
}